<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>麦知网——学问有余，可为人师</title>

<!-- Bootstrap core CSS -->
<link href="../../css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="../../css/non-responsive.css" rel="stylesheet">
<link href="../../css/font-awesome.min.css" rel="stylesheet">

<link href="../../css/theReward.css" rel="stylesheet">  
<link href="../../css/sco.message.css" rel="stylesheet">
<link href="../../css/scojs.css" rel="stylesheet">  
 	<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
	<script src="../../js/jquery.min.js"></script>
<script src="../../js/logout.js"></script>	
	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script src="../../js/bootstrap.js"></script>
		
	<script src="../../js/sco.message.js"></script>
<script src="../../js/message.js"></script>
<script src="../../js/bad.js"></script>
	

	<script type="text/javascript">
	window.onload=function(){
			array=window.location.href.split('#');//alert(array[1]);
			if(array[1]){
				$(window).scrollTop($("."+array[1]).offset().top-100);
			}
		}
		function tr_commit(){
			$("#tr_commit").toggle();
		}
		
	var xmlHttp; 

	function createXMLRequest(){
		if(window.ActiveXObject){
			xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
		} else if(window.XMLHttpRequest){
			xmlHttp=new XMLHttpRequest();
		}
	}
	//悬赏的回复
	function comment_reward(id){
		createXMLRequest();                       
		var content=document.getElementById("reOfReward_texta").value;
		var url="/rewards/addreview/?content="+content+"&reward_id="+id;
		xmlHttp.open("GET",url);
		xmlHttp.onreadystatechange=function(e){
			if(xmlHttp.readyState==4 && xmlHttp.status==200){
					re_array=xmlHttp.responseText.split(',');

					str1='<div id="ajax_comment" style="padding-bottom:40px;"></div><div class="pull-left tc_commit1"><div><img src="'+re_array[3]+"/"+re_array[0]+'" class="img-circle" width="100%"/></div></div>';
					str2='<div class="pull-left tc_commit2"><div class="topdirection2 pull-left"></div><div class="pull-left tc_commit32"><div>';
					str3='<span class="tc_commit_name"><a href="/users/home/?u_id='+re_array[2]+'">'+re_array[1]+'</a>留言：</span><span class="tc_time pull-right">刚刚更新</span><div class="clearfix"></div></div>';
					str4='<div class="tc_commit_content">'+content+'</div></div></div><div class="clearfix"></div>';
			        var strr=str1+str2+str3+str4;

					if(re_array[0]) {
						$("#ajax_comment").html(strr);
						$("#ajax_comment").removeAttr("id");
						$("#reOfReward_texta").val('');
						$("#tr_commit").hide();
						
						e.preventDefault();
			    		$.scojs_message('您回复成功！', $.scojs_message.TYPE_OK);
					}else{
						e.preventDefault();
			    		$.scojs_message('服务器出错啦～ ：）', $.scojs_message.TYPE_ERROR);
					} 
				} else {
					e.preventDefault();
			    	$.scojs_message('服务器有小怪兽在捣乱～我们正在尽力捕捉～ ：）', $.scojs_message.TYPE_ERROR);
				}
			};
			xmlHttp.send(); 
	}

//揭榜
	function uncover(id){
		createXMLRequest();                       
		var url="/rewards/uncover/?reward_id="+id;
		xmlHttp.open("GET",url);
		xmlHttp.onreadystatechange=function(e){
			if(xmlHttp.readyState==4 && xmlHttp.status==200){
					//re_array=xmlHttp.responseText.split(',');
					if(xmlHttp.responseText) {
						$("#jiebang").html('<span><button type="button" class="btn btn-warning" disabled="disabled">您已揭榜</button></span>');
						e.preventDefault();
			    		$.scojs_message('您揭榜成功！', $.scojs_message.TYPE_OK);
					}else{
						e.preventDefault();
			    		$.scojs_message('服务器出错啦～ ：）', $.scojs_message.TYPE_ERROR);
					} 
				} else {
					e.preventDefault();
			    	$.scojs_message('服务器有小怪兽在捣乱～我们正在尽力捕捉～ ：）', $.scojs_message.TYPE_ERROR);
				}
			};
			xmlHttp.send(); 
	}
		
	</script>
</head>
<body>
	{% include 'public/common/header.html' %}
	<div class="container" style="margin-top:45px">
		<div class="row">
<!-- left div -->
			<div class="col-xs-3">
<!-- 举报 -->
				<div style="width:100%;padding-bottom:20px;">
					<button type="button" class="btn btn-danger btn-small" style="
					width:100%;" data-toggle="modal" data-target="#bad_any">举报本悬赏</button>

					<div class="modal fade" id="bad_any" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					  <div class="modal-dialog">
					    <div class="modal-content">
					      <div class="modal-header">
					        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					        <h4 class="modal-title">举报原因</h4>
					      </div>
					      <div class="modal-body">
					        <textarea class="form-control" id="bad_content" style="height:120px;resize:none;"></textarea>
					      </div>
					      <div class="modal-footer">
					      	
					        <button type="button" onclick="bad_send({{r_id}},4);" class="btn btn-primary">举报</button>
					      </div>
					    </div><!-- /.modal-content -->
					  </div><!-- /.modal-dialog -->
					</div><!-- /.modal -->
				</div>
<!-- 举报结束 -->
				<div class="tr_teacher">
					<div><b>发布者信息</b></div>	
					<div>
						<div class="pull-left tr_tea_img">
							<a href=""><img src="{{areward.11}}/{{areward.6}}" width="100%"/></a>
						</div>
						<div class="pull-left tr_tea_name">
							<a href="" title="{{areward.5}}"><b>{{areward.5}}</b></a>
						</div>
						<div class="modal fade" id="myModal{{areward.12}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
						  <div class="modal-dialog">
						    <div class="modal-content">
						      <div class="modal-header">
						        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						        <h4 class="modal-title">发送私信给{{areward.5}}</h4>
						      </div>
						      <div class="modal-body">
						        <textarea class="form-control" id="message{{areward.12}}" style="height:113px"></textarea>
						      </div>
						      <div class="modal-footer">
						      	<span id='messageresult{{areward.5}}'></span>
						        <button type="button" onclick="connected({{areward.12}})" class="btn btn-primary">发送</button>
						      </div>
						    </div><!-- /.modal-content -->
						  </div><!-- /.modal-dialog -->
						</div><!-- /.modal -->
						<div class="clearfix"></div>
					</div>	
					<div>发布过&nbsp;<b>{{areward.7}}</b>&nbsp;个悬赏</div>	
					<div>其中&nbsp;<b>{{areward.8}}</b>&nbsp;个得到解决</div>	
					<div>信用评价：</div>	
					<div>
<!-- 用星星评价的地方    第一个span是黄色星星  第5个span是空心星星  分别循环   -->
						{% for i in yellow_stars %}
						<span class="yellow_star">&#9733</span>
						{% endfor %}
						{% for j in hollow_stars %}
						<span>☆</span>
						{% endfor %}
<!-- 用星星评价的地方 结束 -->							
	
					</div>	
					<div class="tr_mes_btn"><button type="button" class="btn btn-info tr_message_btn" data-toggle="modal" data-target="#myModal{{areward.12}}">私信他</button></div>
				</div>
			</div>
<!-- right div -->
			<div class="col-xs-9">
				<div class="pull-left">
					<div class="topdirection"></div>	
				</div>
				<div class="pull-left tr_tr">
					<div class="tr_time">有效期限：{{areward.2|date:"Y-m-d"}} 至 {{areward.3|date:"Y-m-d"}}</div>
					<div>
						<span class="tr_name"><b>{{areward.0}}</b></span>
						<span style="color:#CD5555;margin-left:20px;">￥{{areward.4}}</span>
						<div class="tr_type pull-right">#{{areward.9}}</div>
						<div class="clearfix"></div>
					</div>
					<div class="tr_intro">
						<div>详细要求：</div>
						<div>{{areward.1}}</div>
					</div>
					<div class="tr_btns">
						{% ifnotequal info.user_id publisher %}
						<span id="jiebang">
						{% ifequal status 0 %}
						<span><button type="button" class="btn btn-warning" onclick="uncover({{areward.10}});">我要揭榜</button></span>
						{% endifequal %}
						{% ifequal status 3 %}
						<span><button type="button" class="btn btn-warning" disabled="disabled">您已揭榜</button>
						{% endifequal %}
						
						{% ifequal status 1 %}
							<a href="/courses/types/create?reward={{enreward}}&method=1&user={{enuser}}&to={{ento}}" type="button" class="btn btn-success">请创建课程</a>
						{% endifequal %}
						{% ifequal status 2 %}
							<a href="/courses/course/lession/auth/{{thereward.course_id}}" type="button" class="btn btn-success">查看课程</a>
						{% endifequal %}
						</span>
						
						</span>
						{% else %}
						<span>
						{% ifequal status 2 %}
							<a href="/courses/course/lession/auth/{{thereward.course_id}}" type="button" class="btn btn-success">查看课程</a>
						{% endifequal %}
						{% ifequal status 4 %}
							<a href="javascript:alert('点什么点，没创建呢！')" type="button" class="btn btn-success">课程仍未创建</a>
						{% endifequal %}
						</span>
						{% endifnotequal %}
						
						<span><a href="javascript:void(0)" type="button" class="btn btn-primary" onclick="tr_commit()">留言</a></span>
					</div>
					<div class="tr_commit" id="tr_commit">
						<form action="" method="post">
							<div class="pull-left tr_textarea">
								<textarea id="reOfReward_texta"></textarea>
							</div>
							<div class="pull-left tr_com_btn">
								<button type="button" class="btn btn-info" onclick="comment_reward({{areward.10}});">留言</button>	
							</div>
							<div class="clearfix"></div>
						</form>
					</div>
					<div>

						<div id="ajax_comment"></div>
<!-- 一条留言   循环开始处 -->
{% for r in re_rewards %}
						<div class="tc_commit dingwei_{{r.6}}" style="padding-top:25px;">
							
							<div class="pull-left tc_commit1">
								<div><img src="{{r.5}}/{{r.0}}" class="img-circle" width="100%"/></div>
							</div>
							<div class="pull-left tc_commit2">
								<div class="topdirection2 pull-left"></div>
								<div class="pull-left tc_commit32">
									<div>
										<span class="tc_commit_name"><a href="{% url 'users:home' r.4 %}">{{r.1}}</a>留言：</span>
										<span class="tc_time pull-right">{{r.3|date:"Y-m-d H:m:s"}}</span>
										<div class="clearfix"></div>
									</div>
									<div class="tc_commit_content">{{r.2}}</div>
								</div>
							</div>
							<div class="clearfix"></div>
						</div>
<!-- 一条留言   循环结束处 -->		{% endfor %}
					<ul class="pager">
							{% if re_rewards.has_previous %}
							  <li><a href="?page={{ re_rewards.previous_page_number }}">&larr;上一页</a></li>
							{% endif %}
							共 {{ re_rewards.number }} 页  第 {{ re_rewards.paginator.num_pages }} 页.
							{% if re_rewards.has_next %}
							  <li><a href="?page={{ re_rewards.next_page_number }}">下一页&rarr;</a></li>
							{% endif %}
						</ul>					
					</div>
				</div>
				<div class="clearfix"></div>
			</div>
		</div>
	</div>
	


	

</body>
</html>
